package com.chushouya.controller.manager.api;

import com.chushouya.common.annotations.AuthSkip;
import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.schema.Response;
import com.chushouya.manager.dto.api.doorservice.DoorServiceCheckRequest;
import com.chushouya.manager.dto.api.doorservice.DoorServiceCheckResponse;
import com.chushouya.manager.service.api.DoorServiceApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 上门服务API控制器
 * 提供上门服务相关功能
 * 
 * @author chushouya
 */
@Api(tags = ServiceType.API + "上门服务接口")
@RestController
@RequestMapping(ServiceType.API + "/doorService")
public class DoorServiceApiController {

    @Resource
    private DoorServiceApiService doorServiceApiService;

    @AuthSkip
    @ApiOperation("检查是否可以上门服务")
    @PostMapping("/check")
    public Response<DoorServiceCheckResponse> checkDoorService(@RequestBody @Valid DoorServiceCheckRequest request) {
        DoorServiceCheckResponse response = doorServiceApiService.checkDoorServiceAvailable(request);
        return Response.success(response);
    }

    @AuthSkip
    @ApiOperation("根据区域代码检查是否可以上门服务")
    @GetMapping("/check/{districtCode}")
    public Response<DoorServiceCheckResponse> checkDoorServiceByCode(@PathVariable String districtCode) {
        DoorServiceCheckResponse response = doorServiceApiService.checkDoorServiceAvailable(districtCode);
        return Response.success(response);
    }

    @AuthSkip
    @ApiOperation("根据区域代码检查是否可以上门服务（查询参数）")
    @GetMapping("/check")
    public Response<DoorServiceCheckResponse> checkDoorServiceByParam(@RequestParam String districtCode) {
        DoorServiceCheckResponse response = doorServiceApiService.checkDoorServiceAvailable(districtCode);
        return Response.success(response);
    }
}
